require 'rubygems'
gem 'soap4r'
require 'soap/wsdlDriver'
require 'soap/header/simplehandler'
require 'defaultDriver.rb'
require 'authStub.rb'

#Async update options
#options = CreateOptions.new(nil,nil,nil,nil,nil,nil,nil,nil,'Asynchronous')
#Upsert update options
options = UpdateOptions.new(nil,nil,SaveOption.new('QueryDefinition','UpdateAdd'),nil,nil,nil,nil,nil,nil,nil,nil,nil)
#options = nil

customerKey = 'API-Test-1'
objectID = 'e7fbb84d-214f-4235-b6b7-be13c03587b4'
date = Date.today.strftime("%m/%d/%Y")
desc = customerKey + ' created through the API ' + date
#query = "SELECT s.FirstName, s.EmailAddress FROM APITestDe0 s WHERE s.EmailAddress LIKE '%bh.exacttarget.com'"
query = nil
queryDef = QueryDefinition.new(nil,nil,nil,nil,nil,nil,objectID,customerKey,nil,nil,customerKey,desc,nil,nil,query,nil,InteractionBaseObject.new(nil,nil,nil,nil,nil,nil,nil,'APITestDe1',nil,nil,'APITestDe1',nil,nil),'Overwrite',nil,nil,nil)
apiObj = queryDef

resp = $driver.update(UpdateRequest.new(options,[*apiObj]))